﻿@model IEnumerable<CmsAdminRevisionViewModel>

@{
    int index = Model.Any() ? Model.Count() : 0;
    int startIndex = index;
}

@functions{
    string RowClass(CmsAdminRevisionViewModel item)
    {
        return item.IsLatestCompletedRevision ?
            "b-form_theme_yellow" :
            "b-form_theme_white";
    }
}

@if (Model.Any())
{
foreach (var item in Model)
{
    <div class="b-form b-form__revs b-form_bordered @RowClass(item)">
	    <div class="b-form__head">
	    	<table width="100%">
	    		<tr>
	    			<td width="120"><b>Revision:</b> @index</td>
	    			<td width="220"><b>Author:</b> @item.Author</td>
	    			<td width="250"><b>Time &amp; date:</b> @item.CreationDate</td>
        @if (item.IsLatestCompletedRevision)
        {
            		<td>Current front-end version</td>
        }
        <td><a class="page-preview" href="@Url.Action("Preview", "CmsPage", new { id = item.Id })"  target="_blank" rel="@item.Id">Preview</a></td>
        @if (index < startIndex)
        {
            		<td><a href="@string.Format("{0}/{1}/{2}", ViewBag.ViewUrl, item.Id, item.LatestRevisionId)">View content</a></td>
        }
        </tr>
	    	</table>
		</div>
    </div>
    index--;
}
}